<template>
  <el-container>
    <el-header style="border-bottom: 1px solid rgba(255,255,255,0.12)">
      <p style="font-family: MicrosoftYaHei;font-size: 16px;color: #7DDAFF;">维修统计报表</p>
    </el-header>
    <el-main>
      <el-row class="btn-group">
        <el-button class="btn" ><span>导出</span><i class="el-icon-download"></i></el-button>
      </el-row>
      <el-table :data="dataList" v-loading="listLoading" element-loading-text="给我一点时间"
                element-loading-background="rgba(0, 0, 0, .3)"
                height="500"
                :row-class-name="tableRowClassName"
                style="width: 100%;padding-top: 0px;background-color: #1B4685"
                ref="parkingMagTable" @selection-change="handleSelectChangeParkingMag">
        <el-table-column fixed type="selection" width="55"></el-table-column>
        <el-table-column fixed sortable align="center" label="设备编号"  prop="equipment_no">
          <template slot-scope="scope">
            <span>{{scope.row.equipment_no}}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="设备位置" width="150" sortable prop="equipment_site">
          <template slot-scope="scope">
            <span>{{scope.row.equipment_site}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="设备类型"  sortable prop="equipment_type">
          <template slot-scope="scope">
            <span>{{scope.row.equipment_type}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="状态"  sortable prop="park_statusname">
          <template slot-scope="scope">
            <span>{{scope.row.equipment_status}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="发生故障时间" width="150" sortable prop="park_dllxname">
          <template slot-scope="scope">
            <span>{{scope.row.equipment_buy_time}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="故障修复时间" width="150" sortable prop="park_dllxname">
          <template slot-scope="scope">
            <span>{{scope.row.equipment_buy_time}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="管理单位"sortable prop="park_sfbz">
          <template slot-scope="scope">
            <span>{{scope.row.equipment_manager}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="维保单位" sortable prop="park_road">
          <template slot-scope="scope">
            <span>{{scope.row.equipment_operator}}</span>
          </template>
        </el-table-column>


        <!--<el-table-column fixed="right" align="center" width="100" label="操作">-->
          <!--<template slot-scope="scope">-->
            <!--<el-dropdown trigger="click" @command="handleCommand">-->
              <!--<el-button class="btn-drop-down" @click="selectRow(scope.row)">-->
                <!--<i class="el-icon-arrow-down"></i>-->
              <!--</el-button>-->
              <!--<el-dropdown-menu slot="dropdown">-->
                <!--<el-dropdown-item command="edit">编辑</el-dropdown-item>-->
                <!--<el-dropdown-item command="del">删除</el-dropdown-item>-->
              <!--</el-dropdown-menu>-->
            <!--</el-dropdown>-->
          <!--</template>-->
        <!--</el-table-column>-->
      </el-table>
    </el-main>
    <el-footer>
      <el-pagination style="margin-top: 16px" background @size-change="handleSizeChangeParkingMag"
                     @current-change="handleCurrentChangeParkingMag"
                     :current-page="listQuery.page" :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit"
                     layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </el-footer>
    <el-dialog :title="'导入'" :visible.sync="dialogUploadVisible" center>
      <el-upload
        class="upload-demo" ref="upload" action="https://jsonplaceholder.typicode.com/posts/"
        :on-preview="handlePreview"
        :on-remove="handleRemove"
        :file-list="fileList"
        :auto-upload="false">
        <el-button slot="trigger" type="primary">选取文件</el-button>
        <!--<el-button style="margin-left: 20px;" type="success" @click="submitUpload">上传到服务器</el-button>-->
        <div slot="tip" class="el-upload__tip">只能上传XXX文件，且不超过500kb</div>
      </el-upload>
    </el-dialog>
  </el-container>

</template>

<script>
  /* eslint-disable */
  import ElContainer from "element-ui/packages/container/src/main";
  import ElHeader from "element-ui/packages/header/src/main";
  import ElMain from "element-ui/packages/main/src/main";
  import ElFooter from "element-ui/packages/footer/src/main";

  export default {
    components: {
      ElFooter,
      ElMain,
      ElHeader,
      ElContainer,
    },
    name: "equip-statis-table",
    props: ['searchList', 'listLoadingParkingMag'],
    watch: {
      searchList(val) {
        this.dataList = val.list
        this.total = val.count
      },
      listLoadingParkingMag(val) {
        this.listLoading = val
      }
    },
    data() {
      return {

        listLoading: false,
        downloadLoading: false,
        dialogCreateVisible: false,
        dialogUploadVisible: false,
        dialogStatusParkMag: '',
        dataList: [],
        selectList: [],
        fileList: [],
        total: 10,
        pValue:21,
        tempParkMag: {
          park_no: '',
          park_name: '',
          park_placeno: '',
          park_placeStart: '001',
          park_ssdw: '',
          park_ssdwname: '', park_sfbzname: '',
          park_sfbz: '', park_roadno: '', park_road: '', park_dllx: '',
          park_jdbsc: '', park_sroad: '', park_eroad: '', park_dlnc: '',
          park_sffs: '', park_jcfs: '', park_long: '', park_lati: '',
          park_sdate: '', park_edate: '', park_status: '1', park_remark: '',

          equipment_site: '',
          equipment_desc: '',
          equipment_status: '',
          equipment_type: '',
          equipment_person: '',
          equipment_model: '',
          equipment_manager: '',
          equipment_operator: '',
          equipment_buy_time: '',
          equipment_long: '',
          equipment_lati: '',
        },
        listQuery: {
          page: 1,
          limit: 20
        }
      }
    },
    methods: {
      handleCreateParkingMag() {
        this.resetTemp()
        this.dialogCreateVisible = true
        this.dialogStatusParkMag = 'create'
      },
      handleUpdateParkingMag() {
        // if(this.selectList.length!=1){
        //   this.$message({
        //     showClose: true,
        //     message: '请选择一条进行编辑',
        //     type: 'warning',
        //     duration: 2000
        //   });
        //   return
        // }
        this.dialogStatusParkMag = 'update'
        // this.tempParkMag = Object.assign({}, this.selectList[0]) // copy obj
        this.dialogCreateVisible = true
      },
      handleDeleteParkingMag() {
        this.deleteDataParkMag(this.selectList)
      },
      handleDownloadParkingMag() {
        if (this.selectList.length) {

        } else {
          this.$message({
            showClose: true,
            message: '至少选择一条',
            duration: 2000,
            type: 'warning'
          })
        }
        this.downloadLoading = true
      },
      handleDownloadParkingMagExcel() {
      },
      handleImport() {
        this.dialogUploadVisible = true
      },
      handleSelectChangeParkingMag(val) {
        this.selectList = val
      },
      handleSizeChangeParkingMag(val) {
        this.listQuery.limit = val
        this.$emit("handleSizeChangeParkingMag", val)
      },
      handleCurrentChangeParkingMag(val) {
        this.listQuery.page = val
        this.$emit("handleCurrentChangeParkingMag", val)
      },

      resetTemp() {
        this.tempParkMag = {
          park_no: '',
          park_name: '',
          park_placeno: '',
          park_placeStart: '001',
          park_ssdw: '',
          park_ssdwname: '', park_sfbzname: '',
          park_sfbz: '', park_roadno: '', park_road: '', park_dllx: '',
          park_jdbsc: '', park_sroad: '', park_eroad: '', park_dlnc: '',
          park_sffs: '', park_jcfs: '', park_long: '', park_lati: '',
          park_sdate: '', park_edate: '', park_status: '1', park_remark: ''
        }
      },

      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePreview(file) {
        console.log(file);
      },
      tableRowClassName({ row, rowIndex }) {
        if (rowIndex % 2 === 0) {
          return 'one-row';
        }
        return '';
      }


    }
  }
</script>

<style scoped>
  .btn-group > .el-button span {
    display: none;
  }

  .btn-group > .el-button:hover {
    background-color: #409EFF;
  }

  .btn-group > .el-button:hover span {
    display: block;
  }

  .btn-group > .el-button:hover i {
    display: none;
  }
</style>
